﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Shared/OneColumn.Master" AutoEventWireup="true"
 ValidateRequest="false" CodeBehind="Posts.aspx.cs" Inherits="SharingCenter.Web.Mod.Groups.Posts.Posts" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitlePlaceHolder" runat="server">
<asp:Literal ID="ltrTitle" runat="server"></asp:Literal>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<myuc:GroupHeader ID="GroupHeader1" runat="server" GroupIdQueryStringField="id" />
<myuc:GenericTabs ID="LinkListTabs2" runat="server" Section="GroupPage" SelectedItem="2" AddPageQueryString="true" PreservedQueryStringFields="id" />
<div class="thread">
        <div class="tt fc">
            <div class="left t ctn3 sz-m">
                <strong>标题:
                    <asp:Label ID="ltrMainPostTitle" runat="server" /></strong>
            </div>
            <div class="right ctn3">
                阅读:
                <asp:Label ID="lblViewCount" runat="server" />
                回复:
                <asp:Label ID="lblPostCount" runat="server" />
            </div>
        </div>
        <asp:ListView runat="server" ID="lvPosts" DataSourceID="LinqDataSource1">
            <LayoutTemplate>
                <div runat="server" id="itemPlaceholder" />
                </div>
            </LayoutTemplate>
            <ItemTemplate>
                <div class="thread-t">
                    <table cellspacing="0" class="tb-full" cellpadding="0">
                        <tr>
                            <td>
                                <div class="fc ctn1">
                                    <div class="left ctn-p-r a">
                                        <myuc:ThumbAvatar ID="AvatarThumbnail1" UserId='<%#Eval("PostUserId") %>' runat="server" />
                                        <div class="textcenter">
                                        </div>
                                    </div>
                                    <div class="left c ">
                                        <div class="bdr-b fc">
                                            <asp:Label ID="Label2" CssClass="left ctn-p-r" runat="server" Text='<%#Convert.ToInt32(Eval("PostIndex")) == 1 ? "顶楼" : Eval("PostIndex", "{0}楼") %>'></asp:Label>
                                            <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%#!Convert.ToBoolean(Eval("IsDeleted")) %>'>
                                                <asp:Label ID="Label1" CssClass="left litetext" runat="server" Text='<%#Eval("PostDate", "发表于: {0:M月d日 HH:mm}") %>' />
                                                <ul class="pt right">
                                                   <%-- <li>
                                                        <asp:LoginView ID="LoginView1" runat="server">
                                                            <AnonymousTemplate>
                                                                <asp:LoginStatus ID="LoginStatus1" runat="server" LoginText="回复" />
                                                            </AnonymousTemplate>
                                                            <LoggedInTemplate>
                                                                <asp:LinkButton ID="LinkButton1" runat="server" Text="回复" />
                                                            </LoggedInTemplate>
                                                        </asp:LoginView>
                                                    </li>--%>
                                                    <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible='<%#Eval("PostUserId").ToString() == SharingCenter.Web.WebProfile.Current.UserId.ToString() %>'>
                                                        <li>
                                                            <asp:HyperLink NavigateUrl='<%#Eval("PostId", "Edit.aspx?p={0}")+"&id="+Request.QueryString["id"]+"&t="+Request.QueryString["t"] %>' ID="LinkButton2"
                                                                runat="server" Text="修改" /></li>
                                                    </asp:PlaceHolder>
                                                    <asp:PlaceHolder ID="PlaceHolder3" runat="server" Visible='<%#Eval("Sc_PostThread.CreatorUserId").ToString() == SharingCenter.Web.WebProfile.Current.UserId.ToString() && Convert.ToInt32(Eval("PostIndex")) > 1 %>'>
                                                        <li>
                                                            <asp:LinkButton ID="LinkButton4" runat="server" CommandName="DeletePost" CommandArgument='<%#Eval("PostId") %>'>删除</asp:LinkButton>
                                                        </li>
                                                    </asp:PlaceHolder>
                                                    <%--<li>
                                                        <asp:LinkButton ID="LinkButton3" runat="server" Text="举报" /></li>--%>
                                                </ul>
                                            </asp:PlaceHolder>
                                        </div>
                                        <div class="sz-m ctn-p-b">
                                            <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex='<%#Convert.ToBoolean(Eval("IsDeleted")) ? 1 : 0 %>'>
                                                <asp:View ID="View1" runat="server">
                                                    <asp:Literal ID="Literal1" runat="server" Text='<%#Eval("PostContent") %>' />
                                                    <cc:UserSignature ID="UserSignature1" AddHorizontalBar="false" CssClass="sig" runat="server"
                                                        UserId='<%#Eval("PostUserId") %>' />
                                                </asp:View>
                                                <asp:View ID="View2" runat="server">
                                                    <div class="litetext bdr-all ctn2" style="margin-top:1em;">该回复已被删除。</div>
                                                </asp:View>
                                            </asp:MultiView>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </ItemTemplate>
        </asp:ListView>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="SharingCenter.Web.Classes.scDataContext"
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" OrderBy="PostDate"  StoreOriginalValuesInViewState="false"
            TableName="Sc_Posts" Where="ThreadId == @ThreadId" EnableViewState="false">
            <InsertParameters>
                <asp:Parameter DefaultValue="true" Name="IsApproved" Type="Boolean" />
                <asp:Parameter DefaultValue="false" Name="IsDeleted" Type="Boolean" />
                <asp:ProfileParameter PropertyName="UserId" Name="PostUserId" />
                <asp:QueryStringParameter QueryStringField="t" Name="ThreadId" />
                <asp:Parameter Name="PostDate" Type="DateTime" />
                <asp:Parameter Name="LastUpdateDate" Type="DateTime" />
                <asp:Parameter Name="PostType" />
                <asp:Parameter Name="PostSignature" DefaultValue="" Type="String" Direction="Input" />
                <asp:Parameter Type="Int32" Name="PostIndex" DefaultValue="1" />
            </InsertParameters>
            <WhereParameters>
                <asp:QueryStringParameter DbType="Guid" Name="ThreadId" QueryStringField="t" />
            </WhereParameters>
        </asp:LinqDataSource>
        <asp:FormView ID="FormView1" runat="server" DataSourceID="LinqDataSource1" DefaultMode="Insert"
            CellSpacing="0" CellPadding="0" Width="100%">
            <InsertItemTemplate>
                <div class="ctn2 qr">
                    <table>
                        <tr>
                            <td>
                                主题:
                            </td>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtReplyTitle" runat="server" Style="width: 500px"
                                    Text='<%#Bind("PostTitle") %>' OnLoad="txtReplyTitle_Load"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                内容:
                            </td>
                            <td>
                                <myuc:Editor runat="server" ID="Editor1" EditorType="Simple" Content='<%#Bind("PostContent") %>' Height="200" Width="550" />
                                
                                <%--<asp:TextBox ID="txtReplyContent" runat="server" TextMode="MultiLine" Rows="6" Style="width: 500px"
                                    Text='<%#Bind("PostContent") %>'></asp:TextBox>--%>
                            </td>
                        </tr>
                    </table>
                    <div class="actionarea">
                        <asp:LinkButton ID="btnReply" runat="server" CssClass="replybutton" CommandName="Insert">回复</asp:LinkButton>
                    </div>
                </div>
            </InsertItemTemplate>
        </asp:FormView>
        <myuc:MessageBox runat="server" Text="只有圈子成员才能回复。" ID="msgMemberOnlyForReply" ></myuc:MessageBox>
    </div>
</asp:Content>
